package com.wl.代码;
import com.entity.Movie;
import com.entity.Studios;
import com.entity.Ticket;
import com.entity.User;
import com.hcy.Recharge;
import com.jch.Dao.MovieDao;
import com.jch.Dao.StudiosDao;
import com.jch.Dao.TicketDao;
import com.jch.Dao.UserDao;
import com.jch.Index;

import java.awt.*;
import java.awt.event.*;
import java.util.List;
import java.util.concurrent.Callable;

import javax.swing.*;
import javax.swing.border.LineBorder;
import javax.swing.plaf.basic.BasicSplitPaneUI;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.JTableHeader;

public class Move_room extends JFrame {

    /**
     *
     */
    private static final long serialVersionUID = -8534958522857190557L;

    private JScrollPane ScrollPane;// 左

    private JButton jb_Refresh;// 刷新按钮
    private JButton jb_signOut;// 退出按钮


    private JLabel jl_Welcome;// 欢迎您的标签
    private JLabel jl_HotMovies;// 热门电影的标签
    private JLabel jl_MyTicket;// 我的影票标签
    private JLabel jl_FindMovie;// 查找电影的标签
    private JLabel jl_return;//返回标签


    private JScrollPane jScrollPane;// 右

    // 右边面板内容--开始

    private JLabel Film_album;// 电影专辑
    private JLabel Film_album1;// 电影专辑
    private JLabel Film_album2;// 电影专辑
    private JLabel Film_album3;// 电影专辑
    private JLabel Film_album4;// 电影专辑
    private JLabel Film_album5;// 电影专辑

    private JTextArea Film_introduction;// 电影简介
    private JTextArea Film_introduction1;// 电影简介
    private JTextArea Film_introduction2;// 电影简介
    private JTextArea Film_introduction3;// 电影简介
    private JTextArea Film_introduction4;// 电影简介
    private JTextArea Film_introduction5;// 电影简介

    // 右边面板内容--结束


    private Child1 child1;//全局变量
    private Child2 child2;//全局变量
    private Child3 child3;//全局变量
    private Child4 child4;//全局变量
    private Child5 child5;//全局变量
    private Child6 child6;//全局变量
    private Recharge recharge;//全局变量

    private MovieDao movieDao = new MovieDao();
    private UserDao userDao = new UserDao();

    //显示一个小手
    private Cursor hand = new Cursor(Cursor.HAND_CURSOR);

    private  Object[] columnNames = {"影票编号", "用户名", "影院名称", "影院地址", "场厅名字","电影名称 ","开始时间","价格","座位号"};
    
    private Ticket ticket=new Ticket();
    private TicketDao ticketDao=new TicketDao();
    
    public Move_room(JTextField j) {
        // TODO Auto-generated constructor stub
        setTitle("电影购票系统2.0");
        setSize(1000,645);


        String text = j.getText();
//        System.out.println(text);

        User user = userDao.queryUser(text);
        System.out.println(user);


        ScrollPane = new JScrollPane();
        ScrollPane.setLayout(null);// 设置为绝对布局
        ScrollPane.setOpaque(true);// 将右边面板的背景设置为透明
        ScrollPane.setBackground(new Color(245,245,245));// 背景颜色
        ScrollPane.setPreferredSize(new Dimension(130, 645));// 设置边界布局的所站的大小


        jScrollPane = new JScrollPane();
        jScrollPane.setOpaque(true);// 将右边面板的背景设置为透明
        jScrollPane.setBackground(new Color(173,216,230));
        jScrollPane.setPreferredSize(new Dimension(870, 645));// 设置边界布局的所站的大小

        JLabel jLabel = new JLabel(new ImageIcon(Move_room.class.getResource("首页背景.jpeg")));
        jLabel.setBounds(0, 0, 870, 645);
        jScrollPane.setViewportView(jLabel);
        // 右边面板=======================================>开始

        JLabel jl_content = new JLabel("欢迎您进入购票系统，尊敬的用户"+text);
        jl_content.setFont(new Font("微软雅黑", Font.PLAIN, 40));
        jl_content.setForeground(Color.white);//设置字体颜色
        jl_content.setBounds(100, 200, 700, 100);
        jLabel.add(jl_content);


        add(BorderLayout.EAST,jScrollPane);

        // 刷新按钮
        jb_Refresh = new JButton("刷新");
        jb_Refresh.setBounds(0, 0, 65, 30);
        jb_Refresh.setFont(new Font("微软雅黑", Font.PLAIN, 15));
        jb_Refresh.setForeground(Color.black);// 设置字体颜色
        jb_Refresh.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {

                new Move_room(j).repaint();
                dispose();
            }
        });
        jb_Refresh.setCursor(hand);// 放上去显示小手

        ScrollPane.add(jb_Refresh);

        // 退出按钮
        jb_signOut = new JButton("退出");
        jb_signOut.setBounds(65, 0, 65, 30);
        jb_signOut.setFont(new Font("微软雅黑", Font.PLAIN, 15));
        jb_signOut.setForeground(Color.black);// 设置字体颜色
        jb_signOut.setCursor(hand);// 放上去显示小手
        jb_signOut.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                System.exit(-1);
            }
        });
        jb_signOut.registerKeyboardAction(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                System.exit(-1);
            }
            },KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE,0),
                JComponent.WHEN_IN_FOCUSED_WINDOW);

        ScrollPane.add(jb_signOut);

        // 欢迎您的标签
        jl_Welcome = new JLabel("个人信息", JLabel.CENTER);// JLabel.CENTER:设置字体居中
        jl_Welcome.setCursor(hand);// 放上去有小手
        jl_Welcome.setFont(new Font("楷体", Font.PLAIN, 20));// 设置字体大小
        jl_Welcome.setOpaque(true);// 设置标签背景为透明
        jl_Welcome.setForeground(Color.black);// 设置字体颜色
        jl_Welcome.setBackground(new Color(200, 221, 242));// 设置背景颜色
        jl_Welcome.setBounds(0, 36, 128, 30);// 设置位置
        // 鼠标监听事件
        jl_Welcome.addMouseListener(new MouseAdapter() {
            // 鼠标放上去
            @Override
            public void mouseEntered(MouseEvent e) {
                jl_Welcome.setBackground(new Color(128, 128, 128));
            }

            // 鼠标离开时
            @Override
            public void mouseExited(MouseEvent e) {
                jl_Welcome.setBackground(new Color(200, 221, 242));
            }
            //点击鼠标时
            @Override
            public void mouseClicked(MouseEvent e) {
                if (e.getClickCount() == 1){
                    //清楚面板里面的组件
                    jLabel.removeAll();
                    //获取重新重绘的面板并加入jlable
                    JPanel jp_Welcome = Welcome(text);
                    jLabel.add(jp_Welcome);

                    //刷新面板里面组件并重新重绘上去
                    jLabel.repaint();
                    jLabel.revalidate();
                    jScrollPane.setViewportView(jp_Welcome);
                }
            }


        });
        ScrollPane.add(jl_Welcome);

        // 热门电影
        jl_HotMovies = new JLabel("热门电影", JLabel.CENTER);
        jl_HotMovies.setCursor(hand);// 放上去显示小手
        jl_HotMovies.setFont(new Font("楷体", Font.PLAIN, 20));// 设置字体大小
        jl_HotMovies.setOpaque(true);// 设置标签背景为透明
        jl_HotMovies.setForeground(Color.black);// 设置字体颜色
        jl_HotMovies.setBackground(new Color(200, 221, 242));// 设置背景颜色

        jl_HotMovies.setBounds(0, 72, 128, 30);// 设置位置
        // 鼠标监听事件
        jl_HotMovies.addMouseListener(new MouseAdapter() {
            // 鼠标放上去
            @Override
            public void mouseEntered(MouseEvent e) {
                jl_HotMovies.setBackground(new Color(128, 128, 128));
            }

            // 鼠标离开时
            @Override
            public void mouseExited(MouseEvent e) {
                jl_HotMovies.setBackground(new Color(200, 221, 242));
            }

            //点击鼠标时
            @Override
            public void mouseClicked(MouseEvent e) {
                 if (e.getClickCount() == 1){
                    //清楚面板里面的组件
                     jLabel.removeAll();
                     //获取重新重绘的面板并加入jlable
                   JPanel Pane = HotMovies(user);
                     jLabel.add(Pane);

                     //刷新面板里面组件并重新重绘上去
                     jLabel.repaint();
                     jLabel.revalidate();
                     jScrollPane.setViewportView(Pane);
                 }
            }
        });
        ScrollPane.add(jl_HotMovies);
        // 我的影票
        jl_MyTicket = new JLabel("我的影票", JLabel.CENTER);
        jl_MyTicket.setCursor(hand);// 放上去显示小手
        jl_MyTicket.setForeground(Color.black);// 设置字体颜色
        jl_MyTicket.setFont(new Font("楷体", Font.PLAIN, 20));// 设置字体大小
        jl_MyTicket.setOpaque(true);// 设置标签背景为透明
        jl_MyTicket.setBackground(new Color(200, 221, 242));// 设置背景颜色
        jl_MyTicket.setBounds(0, 108, 128, 30);// 设置位置
        // 鼠标监听事件
        jl_MyTicket.addMouseListener(new MouseAdapter() {
            // 鼠标放上去
            @Override
            public void mouseEntered(MouseEvent e) {
                jl_MyTicket.setBackground(new Color(128, 128, 128));
            }

            // 鼠标离开时
            @Override
            public void mouseExited(MouseEvent e) {
                jl_MyTicket.setBackground(new Color(200, 221, 242));
            }
            //点击鼠标时
            @Override
            public void mouseClicked(MouseEvent e) {
                if (e.getClickCount() == 1){
                    //清楚面板里面的组件
                    jLabel.removeAll();
                    //获取重新重绘的面板并加入jlable
                    JPanel jp_MyTicket = MyTicket(user,ticket);
                    jLabel.add(jp_MyTicket);

                    //刷新面板里面组件并重新重绘上去
                    jLabel.repaint();
                    jLabel.revalidate();
                    jScrollPane.setViewportView(jp_MyTicket);
                }
            }

        });
        ScrollPane.add(jl_MyTicket);

        // 查找电影
        jl_FindMovie = new JLabel("查找电影", JLabel.CENTER);
        jl_FindMovie.setCursor(hand);// 放上去显示小手
        jl_FindMovie.setForeground(Color.black);// 设置字体颜色
        jl_FindMovie.setFont(new Font("楷体", Font.PLAIN, 20));// 设置字体大小
        jl_FindMovie.setOpaque(true);// 设置标签背景为透明
        jl_FindMovie.setBackground(new Color(200, 221, 242));// 设置背景颜色
        jl_FindMovie.setBounds(0, 144, 128, 30);// 设置位置
        // 鼠标监听事件
        jl_FindMovie.addMouseListener(new MouseAdapter() {
            // 鼠标放上去
            @Override
            public void mouseEntered(MouseEvent e) {
                jl_FindMovie.setBackground(new Color(128, 128, 128));
            }

            // 鼠标离开时
            @Override
            public void mouseExited(MouseEvent e) {
                jl_FindMovie.setBackground(new Color(200, 221, 242));
            }
            //点击鼠标时
            @Override
            public void mouseClicked(MouseEvent e) {
                if (e.getClickCount() == 1){

                    //清楚面板里面的组件
                    jLabel.removeAll();
                    //获取重新重绘的面板并加入jlable
                    JPanel jp_FindMovie = FindMovie();
                    jLabel.add(jp_FindMovie);

                    //刷新面板里面组件并重新重绘上去
                    jLabel.repaint();
                    jLabel.revalidate();
                    jScrollPane.setViewportView(jp_FindMovie);
                }
            }

        });
        ScrollPane.add(jl_FindMovie);

        //返回按钮
        jl_return = new JLabel("返回登录", JLabel.CENTER);
        jl_return.setBounds(0,180,128, 30);
        jl_return.setFont(new Font("楷体",Font.PLAIN,20));
        jl_return.setOpaque(true);// 设置标签背景为透明
        jl_return.setForeground(Color.black);// 设置字体颜色
        jl_return.setBackground(new Color(200, 221, 242));// 设置背景颜色
        jl_return.setCursor(hand);
        // 鼠标监听事件
        jl_return.addMouseListener(new MouseAdapter() {
            // 鼠标放上去
            @Override
            public void mouseEntered(MouseEvent e) {
                jl_return.setBackground(new Color(128, 128, 128));
            }

            // 鼠标离开时
            @Override
            public void mouseExited(MouseEvent e) {
                jl_return.setBackground(new Color(200, 221, 242));
            }
            //点击鼠标时
            @Override
            public void mouseClicked(MouseEvent e) {
                JDialog dialog = new JDialog();
                dialog.setSize(300,220);

                //背景
                JLabel jl_brougd = new JLabel(new ImageIcon(Move_room.class.getResource("返回背景.jpg")));
                jl_brougd.setBounds(0,0,300,220);
                dialog.add(jl_brougd);

                //否-按钮
                JButton jb_No = new JButton("否");
                jb_No.setOpaque(false);
                jb_No.setForeground(Color.BLACK);
                jb_No.setBounds(20,150,60,30);
                jb_No.addMouseListener(new MouseAdapter() {
                    @Override
                    public void mouseClicked(MouseEvent e) {
                        dialog.dispose();
                    }
                });

                jb_No.registerKeyboardAction(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        dialog.dispose();
                    }
                    },KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE,0),
                        JComponent.WHEN_IN_FOCUSED_WINDOW);

                jl_brougd.add(jb_No);


                //提示
                JLabel jl_Tips = new JLabel("️⚠是否返回登录界面 ! ! !");
                jl_Tips.setOpaque(false);
                jl_Tips.setFont(new Font("微软雅黑",Font.PLAIN,18));
                jl_Tips.setForeground(new Color(245,245,245));
                jl_Tips.setBounds(50,60,240,40);
                jl_brougd.add(jl_Tips);


                //是-按钮
                JButton jb_Yes = new JButton("是");
                jb_Yes.setOpaque(false);
                jb_Yes.setForeground(Color.BLACK);
                jb_Yes.setBounds(220,150,60,30);
                jb_Yes.addMouseListener(new MouseAdapter() {
                    @Override
                    public void mouseClicked(MouseEvent e) {
                        dialog.dispose();
                        dispose();
                        new Index();
                    }
                });

                jb_No.registerKeyboardAction(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        dialog.dispose();
                        dispose();
                        new Index();
                    }
                    },KeyStroke.getKeyStroke(KeyEvent.VK_ENTER,0),
                        JComponent.WHEN_IN_FOCUSED_WINDOW);

                jl_brougd.add(jb_Yes);

                dialog.setResizable(false);
                dialog.setLocationRelativeTo(null);
                dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
                dialog.setVisible(true);

            }
        });
        ScrollPane.add( jl_return);

        add(BorderLayout.WEST,ScrollPane);

        setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        setLocationRelativeTo(null);
        setResizable(false);
        setVisible(true);
    }

    /**
     * @return 我的影票
     * */
    public JPanel MyTicket(User user,Ticket ticket){
        JPanel jp_MyTicket = new JPanel();
        jp_MyTicket.setPreferredSize(new Dimension(870,645));
        // 标签
        JLabel label = new JLabel(new ImageIcon(Move_room.class.getResource("影票背景.jpg")));
        label.setBounds(0,0,870,645);
        jp_MyTicket.add(label);

        List<Ticket> tickets = ticketDao.queryTicket();
        for (Ticket ticket1 : tickets) {
            if (ticket1.getUid()==user.getUid()){
                ticket.setUid(ticket1.getUid());
            }

        }

        final String[][] jl_Tagmode = {{"云南虫谷.jpg", "叶问外传：张天志.jpg", "审死官.jpg", "攀登者.jpg", "荡寇风云.jpg", "钢琴教师.jpg"}};
        final int[] modelIndex = {0};

        // 标签重复模式
        JLabel  jl_playerModel = new JLabel(new ImageIcon(Move_room.class.getResource("云南虫谷.jpg")));
        jl_playerModel.setCursor(hand);
        jl_playerModel.setBounds(325, -20 ,220, 340);
        label.add(jl_playerModel);

        Ticket ticket1 = ticketDao.queryTicket(ticket.getUid());
        System.out.println(ticket1);


        List<Ticket> tickets1 = ticketDao.queryTicket2(ticket.getUid());
        System.out.println(tickets1);



        jl_playerModel.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                if (++modelIndex[0] >= jl_Tagmode[0].length) {
                    modelIndex[0] = 0;// 当前标签模式为第一个
                    // 最后一个模式了，回到第一个
                    jl_playerModel.setIcon(new ImageIcon(Move_room.class.getResource(jl_Tagmode[0][0])));
                } else {
                    jl_playerModel.setIcon(new ImageIcon(Move_room.class.getResource(jl_Tagmode[0][modelIndex[0]])));
                }
            }
        });

        // 创建一个表格，指定 所有行数据 和 表头
//        rowData, columnNames
        StudiosDao studiosDao=new StudiosDao();
        List<Studios> studios = studiosDao.queryStudios(user.getUid());

        Object[][] data=new Object[studios.size()][];
        for (int i = 0; i < studios.size(); i++) {
             Studios studios1=studios.get(i);

           if (user.getUid()==ticket.getUid()){
               Object[] studiosData={studios1.getTid(),user.getuName(),studios1.getsCinemaName(),studios1.getsCinemaAddress(),studios1.getsHallName(),
                       studios1.getsMovieTitle(),studios1.getSstartTime(),studios1.getsPrice(),studios1.getSeat()};
               data[i]=studiosData;
           }


        }


        JTable jt_showData = new JTable();
        jt_showData.setModel(new DefaultTableModel(data,columnNames));
        JTableHeader header = jt_showData.getTableHeader();
        header.setFont(new Font("微软雅黑",Font.PLAIN,12));
        header.setForeground(Color.MAGENTA);
        //设置单元格的样式
        DefaultTableCellRenderer d = new DefaultTableCellRenderer();
        //表格内容居中
        d.setHorizontalAlignment(JLabel.CENTER);
        jt_showData.setDefaultRenderer(Object.class, d);
        jt_showData.setRowHeight(30);//设置表格高度
        //设置表格字体样式
        jt_showData.setFont(new Font("楷体",Font.PLAIN,16));

        jt_showData.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

        JPanel Lower_part = new JPanel();
        Lower_part.setBorder(new LineBorder(new Color(248,248,255),2));
        Lower_part.setBounds(0,310,870,308);

        // 把 表头 添加到容器顶部（使用普通的中间容器添加表格时，表头 和 内容 需要分开添加）
        Lower_part.add(jt_showData.getTableHeader(),BorderLayout.NORTH);

        // 把 表格内容 添加到容器中心
        Lower_part.add(jt_showData, BorderLayout.CENTER);

        label.add(Lower_part);

        //退订
        JButton Unsubscribe = new JButton("退订");
        Unsubscribe.setFont(new Font("微软雅黑",Font.PLAIN,12));
        Unsubscribe.setBounds(780,280,60,20);
        Unsubscribe.setForeground(Color.black);
        Unsubscribe.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
               JDialog dialog = new JDialog();
               dialog.setTitle("退订");
               dialog.setSize(300,250);

               //背景
                JLabel jl_brougd = new JLabel(new ImageIcon(Move_room.class.getResource("退订背景.jpg")));
                jl_brougd.setBounds(0,0,300,250);
                dialog.add(jl_brougd);

                // 设置文本框
                JLabel  twoJLabel = new JLabel("影票编号");
                twoJLabel.setBounds(120, 102, 200, 30);
                twoJLabel.setFont(new Font("宋体", Font.PLAIN, 15));
                twoJLabel.setForeground(new Color(255,0,0));
                jl_brougd.add(twoJLabel);

                //文本框
                JTextField jt_field = new JTextField();
                jt_field.setHorizontalAlignment(SwingConstants.CENTER);
                jt_field.setBounds(50,80,200,30);
                jl_brougd.add(jt_field);

                JButton jb_sure=new JButton("确定");
                jb_sure.setContentAreaFilled(false);
                jb_sure.setFocusPainted(false);
//                jb_sure.setBorder(null);
                jb_sure.setBounds(85,150,100,30);
                jb_sure.addMouseListener(new MouseAdapter() {
                    @Override
                    public void mouseClicked(MouseEvent e) {
                        if("".equals(jt_field.getText())){
                            JOptionPane.showMessageDialog(Move_room.this, "请输入要退订的影票编号");
                            return;
                        }
                        List<Ticket> tickets2 = ticketDao.queryTicket();
                        for (Ticket ticket : tickets2) {
                            if(ticket.getTid()==Integer.parseInt(jt_field.getText())){
                                int i = ticketDao.deleteTicket(Integer.parseInt(jt_field.getText()));
                                int j = userDao.updateAddBalance(45,user.getuName());
                                JOptionPane.showMessageDialog(Move_room.this, "退订成功,返还45元,总余额"+(user.getBalance()+45));
                                dialog.dispose();
                                return;

                            }else {
                                JOptionPane.showMessageDialog(Move_room.this, "无此影票");
                                dialog.dispose();
                                return;
                            }
                        }




                    }
                });
                jl_brougd.add(jb_sure);

                dialog.setLocationRelativeTo(null);
                dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
                dialog.setResizable(false);
                dialog.setVisible(true);
            }
        });
        label.add(Unsubscribe);

        return jp_MyTicket;
    }


    /**
     * @return 欢迎你
     * */
    public JPanel Welcome(String j){
        User user = userDao.queryUser(j);


        JPanel jPane = new JPanel();
        jPane.setPreferredSize(new Dimension(870,645));
        JLabel jl_brougd = new JLabel(new ImageIcon(Move_room.class.getResource("用户背景.jpg")));
        jl_brougd.setBounds(0, 0, 870, 645);
        jPane.add(jl_brougd);
        JLabel jl_Information = new JLabel("您的个人信息如下：",JLabel.CENTER);
        jl_Information.setFont(new Font("楷体", Font.PLAIN, 25));//设置字体大小
        jl_Information.setForeground(Color.white);//设置字体颜色
        jl_Information.setBounds(200, 50, 250, 30);//设置位置
        jl_brougd.add(jl_Information);


        //用户名标签
        JLabel jl_UserName = new JLabel("用户名："+user.getuName(),JLabel.CENTER);
        jl_UserName.setFont(new Font("楷体", Font.PLAIN, 20));//设置字体大小
        jl_UserName.setForeground(Color.white);//设置字体颜色
        jl_UserName.setBounds(30, 100, 200, 30);//设置位置
        jl_brougd.add(jl_UserName);

        JLabel jl_showUser=new JLabel();
        jl_showUser.setFont(new Font("楷体", Font.PLAIN, 20));//设置字体大小
        jl_showUser.setForeground(Color.white);//设置字体颜色
        jl_showUser.setBounds(115, 100, 200, 30);//设置位置
        jl_brougd.add(jl_showUser);

        //余额
        JLabel jl_Balance = new JLabel("您的余额："+user.getBalance(),JLabel.CENTER);
        jl_Balance.setFont(new Font("楷体", Font.PLAIN, 20));//设置字体大小
        jl_Balance.setForeground(Color.white);//设置字体颜色
        jl_Balance.setBounds(310, 100, 200, 30);//设置位置
        jl_brougd.add(jl_Balance);

        JLabel jl_showBalance=new JLabel();/**/
        jl_showBalance.setFont(new Font("楷体", Font.PLAIN, 20));//设置字体大小
        jl_showBalance.setForeground(Color.white);//设置字体颜色
        jl_showBalance.setBounds(405, 100, 200, 30);//设置位置
        jl_brougd.add(jl_showBalance);


        //修改密码
        JLabel jl_Modify = new JLabel("修改密码",JLabel.CENTER);
        jl_Modify.setFont(new Font("楷体", Font.PLAIN, 20));//设置字体大小
        jl_Modify.setForeground(Color.white);//设置字体颜色
        jl_Modify.setBounds(30, 160, 100, 30);//设置位置
        jl_Modify.setOpaque(true);//设置标签背景为透明
        jl_Modify.setBackground(new Color(128,128,128));//设置背景颜色
        jl_brougd.add(jl_Modify);

        //原密码
        JLabel  jl_Original = new JLabel("原密码",JLabel.CENTER);
        jl_Original.setFont(new Font("楷体", Font.PLAIN, 20));//设置字体大小
        jl_Original.setForeground(Color.white);//设置字体颜色
        jl_Original.setBounds(30, 200, 70, 30);//设置位置
        jl_brougd.add(jl_Original);

        //原密码输入框
        JTextField jtf_Original = new JTextField();
        jtf_Original.setBounds(30, 240, 130, 30);
        jtf_Original.setBorder(new LineBorder(Color.LIGHT_GRAY));
        jtf_Original.setFont(new Font("楷体", Font.PLAIN, 18));
        jtf_Original.setForeground(Color.black);
        jl_brougd.add(jtf_Original);


        //新密码
        JLabel jl_NewPassword = new JLabel("新密码",JLabel.CENTER);
        jl_NewPassword.setFont(new Font("楷体", Font.PLAIN, 20));//设置字体大小
        jl_NewPassword.setForeground(Color.white);//设置字体颜色
        jl_NewPassword.setBounds(30, 290, 70, 30);//设置位置
        jl_brougd.add(jl_NewPassword);

        //新密码输入框
        JTextField jtf_NewPassword = new JTextField();
        jtf_NewPassword.setBounds(30, 330, 130, 30);
        jtf_NewPassword.setBorder(new LineBorder(Color.LIGHT_GRAY));
        jtf_NewPassword.setFont(new Font("楷体", Font.PLAIN, 18));
        jtf_NewPassword.setForeground(Color.black);
        jl_brougd.add(jtf_NewPassword);


        //确定的标签
        JLabel jl_Determine = new JLabel("确定",JLabel.CENTER);
        jl_Determine.setFont(new Font("楷体", Font.PLAIN, 20));//设置字体大小
        jl_Determine.setForeground(Color.white);//设置字体颜色
        jl_Determine.setOpaque(true);//设置标签背景为透明
        jl_Determine.setBackground(new Color(128,128,128));//设置背景颜色
        jl_Determine.setBounds(30, 380, 130, 30);//设置位置
        jl_Determine.setCursor(hand);
        jl_Determine.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                if ("".equals(jtf_Original.getText())){
                    JOptionPane.showMessageDialog(Move_room.this, "请输入原密码");
                    return;
                }if ("".equals(jtf_NewPassword.getText())){
                    JOptionPane.showMessageDialog(Move_room.this, "请输入新密码");
                    return;
                }

                    if(jtf_Original.getText().equals(user.getuPass())){
                        if(jtf_NewPassword.getText().equals(user.getuPass())){
                            JOptionPane.showMessageDialog(Move_room.this, "新密码不能与原密码相同");
                            return;
                        }else{
                            int i = userDao.updateUseralterPSW(jtf_NewPassword.getText(),user.getuName());
                            System.out.println(i);
                            JOptionPane.showMessageDialog(Move_room.this, "修改成功");
                            return;
                        }
                    }else {
                        JOptionPane.showMessageDialog(Move_room.this, "原密码输入错误");
                        return;
                    }


            }
        });
        jl_brougd.add(jl_Determine);

        //取消的标签
        JLabel jl_Cancel = new JLabel("取消",JLabel.CENTER);
        jl_Cancel.setFont(new Font("楷体", Font.PLAIN, 20));//设置字体大小
        jl_Cancel.setForeground(Color.white);//设置字体颜色
        jl_Cancel.setOpaque(true);//设置标签背景为透明
        jl_Cancel.setBackground(new Color(128,128,128));//设置背景颜色
        jl_Cancel.setBounds(30, 430, 130, 30);//设置位置
        jl_Cancel.setCursor(hand);
        jl_Cancel.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                jtf_Original.setText("");
                jtf_NewPassword.setText("");
            }
        });
        jl_brougd.add(jl_Cancel);


        //充值按钮
        JButton jb_Recharge = new JButton(new ImageIcon(Move_room.class.getResource("充值按钮.png")));
        jb_Recharge.setBounds(310, 190, 130, 30);//设置位置
        jb_Recharge.setCursor(hand);
        jb_Recharge.setBorderPainted(false);
        //点击事件，进入子窗口
        jb_Recharge.addActionListener(e -> new Recharge(user));
        jl_brougd.add(jb_Recharge);
        return jPane;
    }

    /**
     * @return 热门影院
     * */
    public JPanel HotMovies(User user){
        JPanel Pane = new JPanel();
        Pane.setPreferredSize(new Dimension(870,855));
        JLabel jl_brougd = new JLabel(new ImageIcon(Move_room.class.getResource("背景图片.png")));
        jl_brougd.setBounds(0, 0, 870,855);
        Pane.add(jl_brougd);
        Film_album = new JLabel(new ImageIcon(Move_room.class.getResource("荡寇风云.jpg")));
        Film_album.setBounds(60, 2, 220, 340);
        Film_album.setCursor(hand);// 放上去显示小手
        Film_album.addMouseListener(new MouseAdapter() {
            // 鼠标放上去
            @Override
            public void mouseEntered(MouseEvent e) {
                Film_album.setIcon(new ImageIcon(Move_room.class.getResource("荡寇风云-播放.jpg")));
            }

            // 鼠标离开时
            @Override
            public void mouseExited(MouseEvent e) {
                Film_album.setIcon(new ImageIcon(Move_room.class.getResource("荡寇风云.jpg")));
            }
            //鼠标点击标签时会触发
            public void mouseClicked(MouseEvent e) {

                child1 = new Child1(child1,true,user);

            }

        });
        jl_brougd.add(Film_album);


        Movie movie = movieDao.queryMovie("27");
        Film_introduction = new JTextArea();
        Film_introduction.setBounds(60, 333, 220, 80);
        Film_introduction.setText("片名: "+movie.getmName()+"  评分: "+movie.getmGrade()+"\r\n地区: "+movie.getMlocality()
        +"  语言: "+movie.getMlanguage()+"\r\n类型: "+movie.getmType()+"  时长: "+movie.getmDuration()+"分钟");
        Film_introduction.setFont(new Font("微软雅黑",Font.PLAIN,17));
        jl_brougd.add(Film_introduction);

        Film_album1 = new JLabel(new ImageIcon(Move_room.class.getResource("钢琴教师.jpg")));
        Film_album1.setBounds(312,2, 220, 340);
        Film_album1.setCursor(hand);// 放上去显示小手
        Film_album1.addMouseListener(new MouseAdapter() {
            // 鼠标放上去
            @Override
            public void mouseEntered(MouseEvent e) {
                Film_album1.setIcon(new ImageIcon(Move_room.class.getResource("钢琴教师-播放.jpg")));
            }

            // 鼠标离开时
            @Override
            public void mouseExited(MouseEvent e) {
                Film_album1.setIcon(new ImageIcon(Move_room.class.getResource("钢琴教师.jpg")));
            }
            //鼠标点击标签时会触发
            public void mouseClicked(MouseEvent e) {

                child2 = new Child2(child2, true,user);

            }
        });
        jl_brougd.add(Film_album1);

        Movie movie1 = movieDao.queryMovie("26");
        Film_introduction1 = new JTextArea();
        Film_introduction1.setBounds(312,  333, 220, 80);
        Film_introduction1.setText("片名: "+movie1.getmName()+"  评分: "+movie1.getmGrade()+"\r\n地区: "+movie1.getMlocality()
                +"  语言: "+movie1.getMlanguage()+"\r\n类型: "+movie1.getmType()+"  时长: "+movie1.getmDuration()+"分钟");
        Film_introduction1.setFont(new Font("微软雅黑",Font.PLAIN,17));
        jl_brougd.add(Film_introduction1);

        Film_album2 = new JLabel(new ImageIcon(Move_room.class.getResource("攀登者.jpg")));
        Film_album2.setBounds(554, 2, 220, 340);
        Film_album2.setCursor(hand);// 放上去显示小手
        Film_album2.addMouseListener(new MouseAdapter() {
            // 鼠标放上去
            @Override
            public void mouseEntered(MouseEvent e) {
                Film_album2.setIcon(new ImageIcon(Move_room.class.getResource("攀登者-播放.jpg")));
            }

            // 鼠标离开时
            @Override
            public void mouseExited(MouseEvent e) {
                Film_album2.setIcon(new ImageIcon(Move_room.class.getResource("攀登者.jpg")));
            }
            //鼠标点击标签时会触发
            public void mouseClicked(MouseEvent e) {

                child3 = new Child3(child3, true,user);

            }
        });
        jl_brougd.add(Film_album2);

        Movie movie2 = movieDao.queryMovie("25");
        Film_introduction2 = new JTextArea();
        Film_introduction2.setBounds(554, 333, 220, 80);
        Film_introduction2.setText("片名: "+movie2.getmName()+"  评分: "+movie2.getmGrade()+"\r\n地区: "+movie2.getMlocality()
                +"  语言: "+movie2.getMlanguage()+"\r\n类型: "+movie2.getmType()+"  时长: "+movie2.getmDuration()+"分钟");
        Film_introduction2.setFont(new Font("微软雅黑",Font.PLAIN,17));
        jl_brougd.add(Film_introduction2);

        Film_album3 = new JLabel(new ImageIcon(Move_room.class.getResource("审死官.jpg")));
        Film_album3.setBounds(60, 420, 220, 340);
        Film_album3.setCursor(hand);// 放上去显示小手
        Film_album3.addMouseListener(new MouseAdapter() {
            // 鼠标放上去
            @Override
            public void mouseEntered(MouseEvent e) {
                Film_album3.setIcon(new ImageIcon(Move_room.class.getResource("审死官-播放.jpg")));
            }

            // 鼠标离开时
            @Override
            public void mouseExited(MouseEvent e) {
                Film_album3.setIcon(new ImageIcon(Move_room.class.getResource("审死官.jpg")));
            }
            //鼠标点击标签时会触发
            public void mouseClicked(MouseEvent e) {

                child4 = new Child4(child4, true,user);

            }
        });
        jl_brougd.add(Film_album3);

        Movie movie3 = movieDao.queryMovie("24");
        Film_introduction3 = new JTextArea();
        Film_introduction3.setBounds(60, 750, 220, 80);
        Film_introduction3.setText("片名: "+movie3.getmName()+"  评分: "+movie3.getmGrade()+"\r\n地区: "+movie3.getMlocality()
                +"  语言: "+movie3.getMlanguage()+"\r\n类型: "+movie3.getmType()+"  时长: "+movie3.getmDuration()+"分钟");
        Film_introduction3.setFont(new Font("微软雅黑",Font.PLAIN,17));
        jl_brougd.add(Film_introduction3);

        Film_album4 = new JLabel(new ImageIcon(Move_room.class.getResource("叶问外传：张天志.jpg")));
        Film_album4.setBounds(312, 420, 220, 340);
        Film_album4.setCursor(hand);// 放上去显示小手
        Film_album4.addMouseListener(new MouseAdapter() {
            // 鼠标放上去
            @Override
            public void mouseEntered(MouseEvent e) {
                Film_album4.setIcon(new ImageIcon(Move_room.class.getResource("叶问外传：张天志-播放.jpg")));
            }

            // 鼠标离开时
            @Override
            public void mouseExited(MouseEvent e) {
                Film_album4.setIcon(new ImageIcon(Move_room.class.getResource("叶问外传：张天志.jpg")));
            }
            //鼠标点击标签时会触发
            public void mouseClicked(MouseEvent e) {

                child5 = new Child5(child5, true,user);

            }
        });
        jl_brougd.add(Film_album4);

        Movie movie4 = movieDao.queryMovie("23");
        Film_introduction4 = new JTextArea();
        Film_introduction4.setBounds(312, 750, 220, 80);
        Film_introduction4.setText("片名: "+movie4.getmName()+"  评分: "+movie4.getmGrade()+"\r\n地区: "+movie4.getMlocality()
                +"  语言: "+movie4.getMlanguage()+"\r\n类型: "+movie4.getmType()+"  时长: "+movie4.getmDuration()+"分钟");
        Film_introduction4.setFont(new Font("微软雅黑",Font.PLAIN,17));
        jl_brougd.add(Film_introduction4);

        Film_album5 = new JLabel(new ImageIcon(Move_room.class.getResource("云南虫谷.jpg")));
        Film_album5.setBounds(554, 420, 220, 340);
        Film_album5.setCursor(hand);// 放上去显示小手
        Film_album5.addMouseListener(new MouseAdapter() {
            // 鼠标放上去
            @Override
            public void mouseEntered(MouseEvent e) {
                Film_album5.setIcon(new ImageIcon(Move_room.class.getResource("云南虫谷-播放.jpg")));
            }

            // 鼠标离开时
            @Override
            public void mouseExited(MouseEvent e) {
                Film_album5.setIcon(new ImageIcon(Move_room.class.getResource("云南虫谷.jpg")));
            }
            //鼠标点击标签时会触发
            public void mouseClicked(MouseEvent e) {

                child6 = new Child6(child6, true,user);
            }

        });
        jl_brougd.add(Film_album5);

        Movie movie5 = movieDao.queryMovie("22");
        Film_introduction5 = new JTextArea();
        Film_introduction5.setBounds(554, 750, 220, 80);
        Film_introduction5.setText("片名: "+movie5.getmName()+"  评分: "+movie5.getmGrade()+"\r\n地区: "+movie5.getMlocality()
                +"  语言: "+movie5.getMlanguage()+"\r\n类型: "+movie5.getmType()+"  时长: "+movie5.getmDuration()+"分钟");
        Film_introduction5.setFont(new Font("微软雅黑",Font.PLAIN,17));
        jl_brougd.add(Film_introduction5);
        return Pane;
    }

    /**
     * @return 查找电影
     * */
    public JPanel FindMovie(){
        JPanel jp_FindMovie = new JPanel();
        jp_FindMovie.setPreferredSize(new Dimension(870,645));

        // 背景
        JLabel jl_FindMovie = new JLabel(new ImageIcon(Move_room.class.getResource("查找背景.jpeg")));
        jl_FindMovie.setBounds(0,0,870,645);
        jp_FindMovie.add(jl_FindMovie);

        // 标签
        JLabel jl_lable = new JLabel();
        jl_lable.setOpaque(false);
        jl_lable.setBounds(300,0,200,260);
        jl_FindMovie.add(jl_lable);

        //文本域
        JTextArea jt_area = new JTextArea();
        jt_area.setOpaque(false);
        jt_area.setFont(new Font("微软雅黑",Font.PLAIN,14));
        jt_area.setBounds(504,40,304,180);
        jt_area.setForeground(new Color(0,0,0));
        jl_FindMovie.add(jt_area);

        //搜索框
        JTextField jT = new JTextField();
        jT.setHorizontalAlignment(SwingConstants.CENTER);
        jT.setOpaque(false);
        jT.setFont(new Font("微软雅黑",Font.PLAIN,16));
        jT.setBounds(50,160,160,30);
        jT.setForeground(Color.black);
        jl_FindMovie.add(jT);


        //搜索按钮
        JButton search = new JButton("搜索");
        search.setOpaque(false);
        search.setFont(new Font("微软雅黑",Font.PLAIN,16));
        search.setBounds(220,160,80,30);
        search.setFocusPainted(false);
        search.setContentAreaFilled(false);
        search.setForeground(Color.black);




        search.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                if("".equals(jT.getText())){
                    JOptionPane.showMessageDialog(Move_room.this, "搜索不能为空");
                    return;
                }
                MovieDao movieDao = new MovieDao();
                Movie movie = movieDao.queryMoviemName(jT.getText());


                  if (movie==null){
                      JOptionPane.showMessageDialog(Move_room.this, "无此内容");
                      return;

                  }

                    jl_lable.setIcon(new ImageIcon(Move_room.class.getResource(movie.getmPicaddress())));
                    jt_area.setEnabled(false);
                    jt_area.setText("\r\n\r\n\t  片名: " + movie.getmName() + "  评分: " + movie.getmGrade()
                            + "\r\n\n\t  地区: " + movie.getMlocality() + " 语言:" + movie.getMlanguage() + "\r\n\n\t   类型: " +
                            movie.getmType() + " 时长:" + movie.getmDuration());

            }
        });
        jl_FindMovie.add(search);


        // 表头（列名）
       Object[] columnNames = {"电影编号", "电影名字", "语言", "时长", "类别","分数"};
//
//        // 表格所有行数据
//        Object[][] rowData = {
//                {"1", "葫芦娃", "汉语", "中国", "99","动漫",8.5},
//                {"2", "火影忍者", "日语", "日本", "160","动漫",9.6},
//                {"3", "七龙珠", "日语", "日本","140","动漫",9.0},
//                {"4", "喜羊羊与灰太狼","汉语", "中国", "98", "动漫",7.8},
//                {"5", "妖精的尾巴", "日语", "日本","136.8","动漫",9.4},
//                {"6", "天上掉下个猪八戒", "汉语", "中国","125","动漫",10.0}
//        };

       MovieDao  movieDao=new MovieDao();
        List<Movie> movies = movieDao.queryMovieDesc();
        Object[][] data=new Object[movies.size()][];
//        movies.size()
        for (int i = 0; i < 9 ; i++) {
            Movie movie=movies.get(i);
            Object[] studiosData={movie.getMid(),movie.getmName(),movie.getMlanguage(),movie.getmDuration(),
            movie.getmType(),movie.getmGrade()};
            data[i]=studiosData;
        }

        // 创建一个表格，指定 所有行数据 和 表头
        JTable jt_showData = new JTable();
        jt_showData.setModel(new DefaultTableModel(data,columnNames));
        JTableHeader header = jt_showData.getTableHeader();
        header.setFont(new Font("微软雅黑",Font.PLAIN,12));
        header.setForeground(Color.MAGENTA);
        //设置单元格的样式
        DefaultTableCellRenderer d = new DefaultTableCellRenderer();
        //表格内容居中
        d.setHorizontalAlignment(JLabel.CENTER);
        jt_showData.setDefaultRenderer(Object.class, d);
        jt_showData.setRowHeight(30);//设置表格高度
        //设置表格字体样式
        jt_showData.setFont(new Font("楷体",Font.PLAIN,16));

        jt_showData.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

        JPanel Lower_part = new JPanel();
        Lower_part.setBorder(new LineBorder(new Color(248,248,255),2));
        Lower_part.setBounds(0,310,870,308);

        // 把 表头 添加到容器顶部（使用普通的中间容器添加表格时，表头 和 内容 需要分开添加）
        Lower_part.add(jt_showData.getTableHeader(),BorderLayout.NORTH);

        // 把 表格内容 添加到容器中心
        Lower_part.add(jt_showData, BorderLayout.CENTER);

        jl_FindMovie.add(Lower_part);

        return jp_FindMovie;

    }


    public static void main(String[] args) {
//        new Move_room();
    }
}
